import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

/**
 * Copyright (C) 2013  Arun Lee & Bryce Nagareda
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 *  SundialMathTest.java
 *  Test SundialMath.java calculation
 *  @author Arun Lee
 *  @author briceorbryce
 */
public class SundialMathTest {

	private SundialMath test1;
	
	
	/**
	 */
	@BeforeClass
	public static void setUpBeforeClass() {//
	}

	/**
	 */
	@AfterClass
	public static void tearDownAfterClass() {//
	}

	/**
	 * @throws Exception exception thrown
	 */
	@Before
	public void setUp() throws Exception {
		this.test1 = new SundialMath(21.35, -157.89, 3, "February");
		
	}

	/**
	 */
	@After
	public void tearDown() {//
	}
	
	/**
	 * @throws Exception exception thrown
	 */
	@SuppressWarnings("static-method")
	@Test(expected = MonthDayException.class)  
	public void shouldthrowsException() throws Exception {
		//this block checks if MonthDayException being thrown
		SundialMath fail1 = new SundialMath(21.35, -157.89, 30, "February");
		SundialMath fail2 = new SundialMath(21.35, -157.89, 31, "February");
		SundialMath fail3 = new SundialMath(21.35, -157.89, 31, "April");
		SundialMath fail4 = new SundialMath(21.35, -157.89, 31, "June");
		SundialMath fail5 = new SundialMath(21.35, -157.89, 31, "September");
		SundialMath fail6 = new SundialMath(21.35, -157.89, 31, "November");
		//check if invalid latitude longitude throws exception
		SundialMath fail7 = new SundialMath(1000, 1000, 1, "November");
		SundialMath fail8 = new SundialMath(121.35, -157.89, 1, "November");
		SundialMath fail9 = new SundialMath(21.35, -1571.89, 1, "November");
	}
	
	/**
	 * 
	 */
	@Test
	public void test(){
		assertDouble(Double.valueOf(this.test1.getHourLines()[1]));
	}
	
	/**
	 * @param o the object
	 * @return a check for double or not
	 */
	public static boolean assertDouble(Object o) {
		boolean check = false;
	    if(Double.class.isInstance(o)){
	    		check = true;
	    }
	    else {
	    	check = false;
	    }
		return check;
	}
}
